﻿
/*
 *
 * Copyright (C) 2008 Mattias Blomqvist, patr-blo at dsv dot su dot se
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

using System;
using System.IO;
using System.Collections.Generic;
using System.Xml.Serialization;

using FlowLib.Containers;
using FlowLib.Events;

namespace ClientExample.Containers
{
    public class PathSetting
    {
        public event FmdcEventHandler SettingsUpdated;
        protected string sSettings = null;

        [XmlIgnore()]
        public static string PathSettings
        {
            get
            {
                return AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "Paths.xml";
            }
        }

        public string Settings
        {
            get
            {
                if (sSettings == null)
                {
                    return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
                        Path.DirectorySeparatorChar + "Xmpl" + Path.DirectorySeparatorChar;
                }
                return sSettings;
            }
            set
            {
                sSettings = value;
                ValueUpdated();
            }
        }

        [XmlIgnore()]
        public bool HaveUnSavedInfo
        {
            get;
            set;
        }

        [XmlIgnore()]
        public bool IsWriting
        {
            get;
            set;
        }

        [XmlIgnore()]
        public bool IsReading
        {
            get;
            set;
        }

        public PathSetting()
        {
            SettingsUpdated = new FmdcEventHandler(PathSetting_SettingsUpdated);
        }

        void PathSetting_SettingsUpdated(object sender, FmdcEventArgs e) { }

        public void ValueUpdated()
        {
            HaveUnSavedInfo = true;
            SettingsUpdated(this, new FmdcEventArgs(0, null));
        }
    }
}
